import request from '@/config/request'

// ==================== 统计相关 ====================
export function getStatistics() {
  return request({
    url: '/getStatistics',
    method: 'post',
    data: {}
  })
}

// ==================== 游记管理 ====================
export function getNotesList(params: any) {
  console.log(params)
  return request({
    url: '/getNotesList',
    method: 'get',
        headers: {
      'Accept': 'application/json'
    },
    data: params
  })
}

export function getNoteDetail(id: string) {
  return request({
    url: '/getNoteDetail',
    method: 'post',
    data: { id }
  })
}

export function createNote(data: any) {
  return request({
    url: '/createNote',
    method: 'post',
    data: { data }
  })
}

export function updateNote(id: string, data: any) {
  return request({
    url: '/updateNote',
    data: { id, data }
  })
}

export function deleteNote(id: string) {
  console.log("id", id)
  return request({
    url: '/deleteNote',
    data: { id }
  })
}

// ==================== 攻略管理 ====================
export function getGuidesList(params: any) {
  return request({
    url: '/getGuidesList',
    method: 'post',
    data: params
  })
}

export function getGuideDetail(id: string) {
  return request({
    url: '/getGuideDetail',
    method: 'post',
    data: { id }
  })
}

export function createGuide(data: any) {
  return request({
    url: '/createGuide',
    method: 'post',
    data: { data }
  })
}

export function updateGuide(id: string, data: any) {
  return request({
    url: '/updateGuide',
    method: 'post',
    data: { id, data }
  })
}

export function deleteGuide(id: string) {
  return request({
    url: '/deleteGuide',
    method: 'post',
    data: { id }
  })
}

// ==================== 问答管理 ====================
export function getQAList(params: any) {
  return request({
    url: '/getQAList',
    method: 'post',
    data: params
  })
}

export function getQADetail(id: string) {
  return request({
    url: '/getQADetail',
    method: 'post',
    data: { id }
  })
}

export function createQA(data: any) {
  return request({
    url: '/createQA',
    method: 'post',
    data: { data }
  })
}

export function updateQA(id: string, data: any) {
  return request({
    url: '/updateQA',
    method: 'post',
    data: { id, data }
  })
}

export function deleteQA(id: string) {
  return request({
    url: '/deleteQA',
    method: 'post',
    data: { id }
  })
}

// ==================== 用户管理 ====================
export function getUsersList(params: any) {
  return request({
    url: '/getUsersList',
    data: params
  })
}

export function getUserDetail(id: string) {
  return request({
    url: '/getUserDetail',
    method: 'post',
    data: { id }
  })
}

export function updateUserRole(id: string, role: string) {
  return request({
    url: '/updateUserRole',
    method: 'post',
    data: { id, role }
  })
}

export function updateUserStatus(id: string, status: number) {
  return request({
    url: '/updateUserStatus',
    method: 'post',
    data: { id, status }
  })
}

// ==================== 角色权限管理 ====================
export function getRolesList(params: any) {
  return request({
    url: '/getRolesList',
    method: 'post',
    data: params
  })
}

export function getRoleDetail(id: string) {
  return request({
    url: '/getRoleDetail',
    method: 'post',
    data: { id }
  })
}

export function createRole(data: any) {
  return request({
    url: '/createRole',
    method: 'post',
    data: { data }
  })
}

export function updateRole(id: string, data: any) {
  return request({
    url: '/updateRole',
    method: 'post',
    data: { id, data }
  })
}

export function deleteRole(id: string) {
  return request({
    url: '/deleteRole',
    method: 'post',
    data: { id }
  })
}

export function updateRolePermissions(id: string, permissions: string[]) {
  return request({
    url: '/updateRolePermissions',
    method: 'post',
    data: { id, permissions }
  })
}

// ==================== 轮播图管理 ====================
export function getSwipersList(params: any) {
  return request({
    url: '/getSwipersList',
    method: 'post',
    data: params
  })
}

export function getSwiperDetail(id: string) {
  return request({
    url: '/getSwiperDetail',
    method: 'post',
    data: { id }
  })
}

export function createSwiper(data: any) {
  return request({
    url: '/createSwiper',
    method: 'post',
    data: { data }
  })
}

export function updateSwiper(id: string, data: any) {
  return request({
    url: '/updateSwiper',
    method: 'post',
    data: { id, data }
  })
}

export function deleteSwiper(id: string) {
  return request({
    url: '/deleteSwiper',
    method: 'post',
    data: { id }
  })
}

// ==================== 评论管理 ====================
export function getCommentsList(params: any) {
  return request({
    url: '/getCommentsList',
    method: 'post',
    data: params
  })
}

export function getCommentDetail(id: string) {
  return request({
    url: '/getCommentDetail',
    method: 'post',
    data: { id }
  })
}

export function deleteComment(id: string) {
  return request({
    url: '/deleteComment',
    method: 'post',
    data: { id }
  })
}

export function updateCommentStatus(id: string, status: number) {
  return request({
    url: '/updateCommentStatus',
    method: 'post',
    data: { id, status }
  })
}

export function getCommentRepliesList(commentId: string, params: any) {
  return request({
    url: '/getCommentRepliesList',
    method: 'post',
    data: { commentId, ...params }
  })
}

export function deleteCommentReply(id: string) {
  return request({
    url: '/deleteCommentReply',
    method: 'post',
    data: { id }
  })
}

// ==================== 排行榜管理 ====================
export function getSpotsList(params: any) {
  return request({
    url: '/getSpotsList',
    method: 'post',
    data: params
  })
}

export function getSpotDetail(id: string) {
  return request({
    url: '/getSpotDetail',
    method: 'post',
    data: { id }
  })
}

export function createSpot(data: any) {
  return request({
    url: '/createSpot',
    method: 'post',
    data: { data }
  })
}

export function updateSpot(id: string, data: any) {
  return request({
    url: '/updateSpot',
    method: 'post',
    data: { id, data }
  })
}

export function deleteSpot(id: string) {
  return request({
    url: '/deleteSpot',
    method: 'post',
    data: { id }
  })
}